package com.cblz.bd.common.core.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;

/**
 * 敏感数据修改记录
 * @TableName ba_security_sensitive_data_log
 */
@TableName(value ="ba_security_sensitive_data_log")
@Data
public class BaSecuritySensitiveDataLog implements Serializable {
    /**
     * ID
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 管理员
     */
    private Integer adminId;

    /**
     * 敏感数据规则ID
     */
    private Integer sensitiveId;

    /**
     * 所在数据表
     */
    private String dataTable;

    /**
     * 数据表主键
     */
    private String primaryKey;

    /**
     * 被修改字段
     */
    private String dataField;

    /**
     * 被修改项
     */
    private String dataComment;

    /**
     * 被修改项主键值
     */
    private String idValue;

    /**
     * 修改前
     */
    private String before;

    /**
     * 修改后
     */
    private String after;

    /**
     * 操作者IP
     */
    private String ip;

    /**
     * User Agent
     */
    private String useragent;

    /**
     * 是否已回滚:0=否,1=是
     */
    private Integer isRollback;

    /**
     * 修改时间
     */
    private Long createtime;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        BaSecuritySensitiveDataLog other = (BaSecuritySensitiveDataLog) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getAdminId() == null ? other.getAdminId() == null : this.getAdminId().equals(other.getAdminId()))
            && (this.getSensitiveId() == null ? other.getSensitiveId() == null : this.getSensitiveId().equals(other.getSensitiveId()))
            && (this.getDataTable() == null ? other.getDataTable() == null : this.getDataTable().equals(other.getDataTable()))
            && (this.getPrimaryKey() == null ? other.getPrimaryKey() == null : this.getPrimaryKey().equals(other.getPrimaryKey()))
            && (this.getDataField() == null ? other.getDataField() == null : this.getDataField().equals(other.getDataField()))
            && (this.getDataComment() == null ? other.getDataComment() == null : this.getDataComment().equals(other.getDataComment()))
            && (this.getIdValue() == null ? other.getIdValue() == null : this.getIdValue().equals(other.getIdValue()))
            && (this.getBefore() == null ? other.getBefore() == null : this.getBefore().equals(other.getBefore()))
            && (this.getAfter() == null ? other.getAfter() == null : this.getAfter().equals(other.getAfter()))
            && (this.getIp() == null ? other.getIp() == null : this.getIp().equals(other.getIp()))
            && (this.getUseragent() == null ? other.getUseragent() == null : this.getUseragent().equals(other.getUseragent()))
            && (this.getIsRollback() == null ? other.getIsRollback() == null : this.getIsRollback().equals(other.getIsRollback()))
            && (this.getCreatetime() == null ? other.getCreatetime() == null : this.getCreatetime().equals(other.getCreatetime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getAdminId() == null) ? 0 : getAdminId().hashCode());
        result = prime * result + ((getSensitiveId() == null) ? 0 : getSensitiveId().hashCode());
        result = prime * result + ((getDataTable() == null) ? 0 : getDataTable().hashCode());
        result = prime * result + ((getPrimaryKey() == null) ? 0 : getPrimaryKey().hashCode());
        result = prime * result + ((getDataField() == null) ? 0 : getDataField().hashCode());
        result = prime * result + ((getDataComment() == null) ? 0 : getDataComment().hashCode());
        result = prime * result + ((getIdValue() == null) ? 0 : getIdValue().hashCode());
        result = prime * result + ((getBefore() == null) ? 0 : getBefore().hashCode());
        result = prime * result + ((getAfter() == null) ? 0 : getAfter().hashCode());
        result = prime * result + ((getIp() == null) ? 0 : getIp().hashCode());
        result = prime * result + ((getUseragent() == null) ? 0 : getUseragent().hashCode());
        result = prime * result + ((getIsRollback() == null) ? 0 : getIsRollback().hashCode());
        result = prime * result + ((getCreatetime() == null) ? 0 : getCreatetime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", adminId=").append(adminId);
        sb.append(", sensitiveId=").append(sensitiveId);
        sb.append(", dataTable=").append(dataTable);
        sb.append(", primaryKey=").append(primaryKey);
        sb.append(", dataField=").append(dataField);
        sb.append(", dataComment=").append(dataComment);
        sb.append(", idValue=").append(idValue);
        sb.append(", before=").append(before);
        sb.append(", after=").append(after);
        sb.append(", ip=").append(ip);
        sb.append(", useragent=").append(useragent);
        sb.append(", isRollback=").append(isRollback);
        sb.append(", createtime=").append(createtime);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}